const app = require('express')();
const { validationResult } = require('express-validator');
const queryDetail = require('@/models/history-today/history-today-detail');

const { detailRule } = require('./rule'); // 校验规则

/**
 * @description 历史上的今天列表
 * @param {string}  date.query  - 12-31
 * @param {string}  content_id -  详情 id 12092
 */
app.get('/', detailRule, (req, res) => {
  let err = validationResult(req);
  if (!err.isEmpty()) {
    return res.api_error(err.mapped().date && err.mapped().date.msg, 1002, err.mapped());
  }
  return queryDetail(req, res);
});

module.exports = app;
